#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "tlpi.h"
#include <string.h>
#include <signal.h>

static void
handler(int sig)
{
	printf("PID=%ld: cuaght signal %2d(%s)\n", (long)getpid(), 
			sig, strsignal(sig));
}

int
main(int argc, char *argv[])
{
	struct sigaction sa;
	int j;
	pid_t pid;


	sa.sa_flags = 0;
	sa.sa_handler = handler;
	sigemptyset(&sa.sa_mask);
	if(sigaction(SIGHUP, &sa, NULL) == -1)
		errExit("sigaction() for SIGHUP failed");
	if(sigaction(SIGINT, &sa, NULL) == -1)
		errExit("sigaction() for SIGINT failed");

	printf("Parent PID=%ld\n", (long)getpid());

	
	pid = fork();
	
	if(pid == -1)
		errExit("fork() failed");

	if(pid == 0)
		printf("child PID=%ld\n", (long)getpid());

	for(;;)
		pause();
}
